from .draw import draw_text


class Text:
    """
    文本类
    """
    # 文本对象
    __obj = None
    # 文本 Rect 对象
    __rect = None
    # 文本的内容
    __content = ''
    # 文本是否为激活状态
    __is_active = False
    # 文本的颜色
    __color = (255, 255, 255)
    # 激活状态下的文本颜色
    __color_active = (255, 255, 255)
    # 文本的大小
    __size = 16
    # 文本是否加粗
    __bold = False
    # 文本是否倾斜
    __italic = False
    # 文本的字体
    __font = 'Microsoft YaHei UI'
    # 文本的位置
    __position = (0, 0)
    # 文本是否水平居中
    __is_h_center = False
    # 文本是否垂直居中
    __is_v_center = False

    def __init__(self, content='', is_active=False, color=(255, 255, 255), color_active=(255, 255, 255), size=16, bold=False,
                 italic=False, font='Microsoft YaHei UI', position=(0, 0), is_h_center=False, is_v_center=False):
        self.__content = content
        self.__is_active = is_active
        self.__color = color
        self.__color_active = color_active
        self.__size = size
        self.__bold = bold
        self.__italic = italic
        self.__font = font
        self.__position = position
        self.__is_h_center = is_h_center
        self.__is_v_center = is_v_center

    def draw(self):
        """
        在窗口中绘制文本
        :return:
        """
        text_color = self.__color
        if self.__is_active:
            text_color = self.__color_active
        text_tuple = draw_text(
            self.__content, self.__position, self.__is_h_center, self.__is_v_center, self.__size, text_color,
            self.__bold, self.__italic, self.__font
        )
        self.__obj = text_tuple[0]
        self.__rect = text_tuple[1]

    def get_obj(self):
        return self.__obj

    def get_rect(self):
        return self.__rect

    def set_content(self, content):
        self.__content = content

    def get_is_active(self):
        return self.__is_active

    def set_is_active(self, is_active):
        self.__is_active = is_active

    def get_content(self):
        return self.__content

    def set_color(self, color):
        self.__color = color

    def get_color(self):
        return self.__color

    def set_color_active(self, color_active):
        self.__color_active = color_active

    def get_color_active(self):
        return self.__color_active

    def set_size(self, size):
        self.__size = size

    def get_size(self):
        return self.__size

    def set_bold(self, bold):
        self.__bold = bold

    def get_bold(self):
        return self.__bold

    def set_italic(self, italic):
        self.__italic = italic

    def get_italic(self):
        return self.__italic

    def set_font(self, font):
        self.__font = font

    def get_font(self):
        return self.__font

    def set_position(self, position):
        self.__position = position

    def get_position(self):
        return self.__position

    def set_is_h_center(self, is_h_center):
        self.__is_h_center = is_h_center

    def get_is_h_center(self):
        return self.__is_h_center

    def set_is_v_center(self, is_v_center):
        self.__is_v_center = is_v_center

    def get_is_v_center(self):
        return self.__is_v_center
